package cn.terminus.data.customer.contractrentclause.impl;

import cn.terminus.common.customer.bean.contractrentclause.dto.*;
import cn.terminus.data.customer.contractrentclause.dao.ContractRentClauseDao;
import cn.terminus.data.customer.contractrentclause.mapper.ContractRentClauseMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * 合同租金条款(ContractRentClause)表服务实现类
 *
 * @author makejava
 * @since 2021-07-21 11:01:11
 */
@Repository
public class ContractRentClauseDaoImpl implements ContractRentClauseDao {
    @Resource
    private ContractRentClauseMapper contractRentClauseMapper;

    @Override
    public Integer add(ContractRentClauseNewDto dto) {
        return contractRentClauseMapper.add(dto);
    }

    @Override
    public Integer update(ContractRentClauseEditDto dto) {
        return contractRentClauseMapper.update(dto);
    }

    @Override
    public List<ContractRentClauseResultDto> gets(ContractRentClauseGetsDto dto) {
        return contractRentClauseMapper.gets(dto);
    }

    @Override
    public List<ContractRentClauseResultDto> query(ContractRentClauseQueryDto dto) {
        return contractRentClauseMapper.query(dto);
    }

    @Override
    public Integer delete(ContractRentClauseDeleteDto dto) {
        return contractRentClauseMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<ContractRentClauseResultDto> page(ContractRentClauseQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<ContractRentClauseResultDto> result = (Page<ContractRentClauseResultDto>) contractRentClauseMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), ContractRentClauseResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer deleteWithContractId(Long contractId) {

        return contractRentClauseMapper.deleteWithContractId(contractId);
    }
}
